package com.ltkj.shop.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ltkj.shop.domain.vo.ShopStoreCentersVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ltkj.common.log.annotation.Log;
import com.ltkj.common.log.enums.BusinessType;
import com.ltkj.common.security.annotation.RequiresPermissions;
import com.ltkj.shop.domain.ShopStoreCenters;
import com.ltkj.shop.service.IShopStoreCentersService;
import com.ltkj.common.core.web.controller.BaseController;
import com.ltkj.common.core.web.domain.AjaxResult;
import com.ltkj.common.core.utils.poi.ExcelUtil;
import com.ltkj.common.core.web.page.TableDataInfo;

/**
 * 商店和自提点关联Controller
 * 
 * @author xupf
 * @date 2023-08-29
 */
@Api(tags = "商店和自提点关联")
@RestController
@RequestMapping("/store/centers")
public class ShopStoreCentersController extends BaseController
{
    @Autowired
    private IShopStoreCentersService shopStoreCentersService;

    /**
     * 查询商店和自提点关联列表
     */
    @ApiOperation("查询商店和自提点关联列表")
    @GetMapping("/list")
    public TableDataInfo list(ShopStoreCenters shopStoreCenters)
    {
        startPage();
        List<ShopStoreCenters> list = shopStoreCentersService.selectShopStoreCentersList(shopStoreCenters);
        return getDataTable(list);
    }

    /**
     * 导出商店和自提点关联列表
     */
    @ApiOperation("导出商店和自提点关联列表")
    @RequiresPermissions("shop:centers:export")
    @Log(title = "商店和自提点关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ShopStoreCenters shopStoreCenters)
    {
        List<ShopStoreCenters> list = shopStoreCentersService.selectShopStoreCentersList(shopStoreCenters);
        ExcelUtil<ShopStoreCenters> util = new ExcelUtil<ShopStoreCenters>(ShopStoreCenters.class);
        util.exportExcel(response, list, "商店和自提点关联数据");
    }

    /**
     * 新增商店和自提点关联
     */
    @ApiOperation("新增商店和自提点关联")
    @Log(title = "商店和自提点关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShopStoreCentersVo shopStoreCenters)
    {
        return toAjax(shopStoreCentersService.insertShopStoreCenters(shopStoreCenters));
    }

    /**
     * 删除商店和自提点关联
     */
    @ApiOperation("删除商店和自提点关联")
    @Log(title = "商店和自提点关联", businessType = BusinessType.DELETE)
	@PostMapping("/delete")
    public AjaxResult remove(@RequestBody ShopStoreCentersVo shopStoreCenters)
    {
        return toAjax(shopStoreCentersService.deleteShopStoreCentersByStoreIds(shopStoreCenters));
    }
}
